// 模块引入
const  path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')   //yarn add html-webpack-plugin
const copyWebpackPlugin  = require("copy-webpack-plugin")   //yarn add copy-webpack-plugin


// 信息配置
module.exports = {
    // 开发环境
    mode:'development',
    entry:'./src/app.js',
    output:{
        // 需要引入绝对路径   dev/app.js
        path:path.resolve(__dirname,'../dev'),
        filename:'app.js'
    },

    // 做webpackServer的设置
    devServer:{
           contentBase:path.resolve(__dirname,'../dev'),
           port:8002,
           proxy: {
            '/api': {
              target: 'http://localhost:3000',
              changeOrigin: true
            }
          }
    },

    // loader们
    module:{
        rules:[
           { 
               test:/\.art$/,
               loader:'art-template-loader'
            },
            {
                test:/\.(scss|css)$/,
                loader:['style-loader','css-loader','sass-loader']
            }
        ]
    },
    // 插件们
    plugins:[
        new htmlWebpackPlugin({
            //    以谁为模板
            template:'./index.html',
            //    打包完以后的目标文件
               filename:'index.html' 
        }),
        //    拷贝public source
       new copyWebpackPlugin([{
        from:'./public',
        to:'./public'
    }])
    ]

    
}